﻿using System;
using RuleCode.Table;

namespace map.member
{
    public partial class login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //cbuser.dealcookie();
                dealrequest();
            }
        }
        /// <summary>
        /// 处理request
        /// </summary>
        private void dealrequest()
        {

        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            //处理Cookie
            if (!cbuser.loginWithPermently(TextBox1.Text,
                       TextBox3.Text,CheckBox1.Checked))
            {
                MessageBox.Show(this.Page, "用户名或者密码错误.");
                return;
            }
            //if (! cbuser.login(TextBox1.Text,
            //            TextBox3.Text))
            //{
            //    MessageBox.Show(this.Page, "用户名或者密码错误.");
            //    return;
            //}
            if (this.Request.Params["redirecturl"] == null)
            {
                this.Response.Redirect(ResolveUrl("~/default.aspx"));
            }
            else
            {
                string url = string.Empty;
                if(!String.IsNullOrEmpty(this.Request.Params["redirecturl"]))
                {
                    url += this.Request.Params["redirecturl"];
                
                }
                if (!String.IsNullOrEmpty(this.Request.Params["id"]))
                {
                    url += "&id=";
                    url += this.Request.Params["id"];

                }
                if (!String.IsNullOrEmpty(this.Request.Params["itemid"]))
                {
                    url += "&itemid=";
                    url += this.Request.Params["itemid"];

                }
                this.Response.Redirect(url);
            }
        }
    }
}
